package com.zingrow.web.push.bind.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zingrow.web.push.bind.mapper.BindMapper;
import com.zingrow.web.push.bind.model.Bind;
import com.zingrow.web.push.bind.response.BindResponse;
import com.zingrow.web.push.bind.service.IBindService;

@Service
public class BindService implements IBindService {

	@Autowired
	private BindMapper bindMapper;

	@Override
	public boolean selectSameBybaidu_channel_id(String baidu_channel_id, String user_account) {
		return bindMapper.selectSameBybaidu_channel_id(baidu_channel_id, user_account) > 0;
	}

	@Override
	public boolean insert(Bind bind) {
		return bindMapper.insert(bind) > 0;
	}

	@Override
	public boolean modify(Bind bind) {
		return bindMapper.modify(bind) > 0;
	}

	@Override
	public List<Bind> selectAppByifmId(Integer ifm_id) {
		return bindMapper.selectAppByifmId(ifm_id);
	}

	@Override
	public boolean modifyBadge(Bind bind) {
		return bindMapper.modifyBadge(bind) > 0;
	}

	@Override
	public Bind selectIOSByuserAccount(String baidu_channel_id, String user_account) {
		if (baidu_channel_id == null) {
			baidu_channel_id = "";
		}
		return bindMapper.selectIOSByuserAccount(baidu_channel_id, user_account);
	}

	@Override
	public boolean modifyByAccount(Bind bind) {
		return bindMapper.modifyByAccount(bind) > 0;
	}

	@Override
	public boolean deleteBindByAccountAndChannelId(String baidu_channel_id, String user_account) {
		return bindMapper.deleteBindByAccountAndChannelId(baidu_channel_id, user_account) > 0;
	}

	@Override
	public Integer selectAppVerSionNumberByUserName(String user_account) {
		return bindMapper.selectAppVerSionNumberByUserName(user_account);
	}

	@Override
	public Bind selectAppByUserName(String user_account) {
		return bindMapper.selectAppByUserName(user_account);
	}

	@Override
	public boolean deleteBindByChannelId(String baidu_channel_id) {
		return bindMapper.deleteBindByChannelId(baidu_channel_id) > 0;
	}

	@Override
	public List<BindResponse> selectAppUser(Integer ifm_id) {
		return bindMapper.selectAppUser(ifm_id);
	}

}
